

<template>
    <div class="resume_header">
      <span>公司信息审核</span>
    </div>
    <div class="resume_center">
      <el-table :data="filterTableData.slice((page - 1) * limit,page*limit)" style="width: 100%" height="400px" size="large">
        
        <el-table-column label="提交人" prop="hrName" width="100px" />
        <el-table-column label="提交人电话" prop="hrPhone" width="140px" />
        <el-table-column label="提交时间" prop="confirmTime"  width="240px"/>
        <el-table-column label="审核时间" prop="auditTime" width="240px"/>
        <el-table-column label="审核状态" prop="auditState" width="140px" />
        <el-table-column align="right" min-width="300px"  >
          <template #header>
            <el-input v-model="search" size="default" placeholder="搜索" />
          </template>
          <template #default="scope">
            <el-button size="default" type="primary" @click="handleShowJObInfo(scope.$index, scope.row)">查看</el-button>
        </template>
        </el-table-column>
      </el-table>
      
      <PreAuditEnterpriseDialog v-if="preAuditEInfoDialog" 
      :closePreAuditEInfoDialog="closePreAuditEInfoDialog" 
      :preAuditEInfoDialog="preAuditEInfoDialog" 
  
      />
  
      <div class="pagination">
        <Pagination :page="page" :limit="limit" :handleSizeChange="handleSizeChange" :handleCurrentChange="handleCurrentChange" :filterTableData="filterTableData" :pagesizes="pagesizes" />
      </div>
  
    </div>
   
  </template>
  <script lang='ts' setup>
  import {adminDelectEnterprise,adminGetAuditEnterprise,adminAuditedEnterprise,adminPreAuditEnterprise} from "@/api/adminApi"
  import {eGetAuditEnterprise,ePreAuditEnterprise} from "@/api/enterpriseApi"
  import { computed, ref, onMounted, reactive, watch, onBeforeMount } from 'vue'
  import { useStore } from "vuex"
  import Pagination from "@/components/Pagination.vue"
  import { data,elmessage,formatDate } from "@/hook/hook";
  import {useRouter} from "vue-router"
  import { ElMessageBox } from 'element-plus'

  import PreAuditEnterpriseDialog from "@/components/PreAuditEnterpriseDialog.vue"
  const store = useStore()
  const router=useRouter()
  
  // 表格数据定义
  interface ES {
    auditId:string
    eId:string
    businessName:string
    hrId:string
    hrName:string
    hrPhone:string
    confirmTime:string
    auditTime:string
    auditState:string
    isAudit:string
  }
  const tableData: ES[] = reactive([])
  
  const search = ref('')
  const filterTableData = computed(() =>
    
  tableData.filter(
      (data,index) =>
        !search.value ||
        // 通过岗位名称筛选
        data.businessName.toLowerCase().indexOf(search.value.toLowerCase()) !== -1 
    ) 
  )
  
  
  // 分页器
  const page = ref(1)
  const pagesizes=ref([1,2,3,4,10, 20, 30, 40])
  const limit = ref(10)
  
  const handleSizeChange = (val: number) => {
    limit.value=val
    page.value=1
  }
  const handleCurrentChange = (val: number) => {
    page.value=val
  }
  
  
  // 查看具体修改的内容
  const preAuditEInfoDialog=ref(false)
  
  const e = store.state.adminState.audite
  const getPreAuditEnterpriseInfo=(auditId:string)=>{
    const newData = {
          ...data(),
          auditId: auditId
      }
      ePreAuditEnterprise(newData).then((res: any) => {
          if (res.data["code"] == "200") {
              e.auditId=res.data.datas[0].auditId
              e.eId=res.data.datas[0].eId
              e.eContent=res.data.datas[0].eContent
              e.eSize=res.data.datas[0].eSize
              e.eNature=res.data.datas[0].eNature
              e.eIndustry=res.data.datas[0].eIndustry
              e.eAdvantage=res.data.datas[0].eAdvantage
  
              e.contactName=res.data.datas[0].contactName
              e.contactPhone=res.data.datas[0].contactPhone
              e.contactEmail=res.data.datas[0].contactEmail
              e.contactAddress=res.data.datas[0].contactAddress
  
              e.businessName=res.data.datas[0].businessName
              e.businessSetTime=res.data.datas[0].businessSetTime
              e.businessRegCapital=res.data.datas[0].businessRegCapital
              e.businessLegalRepresentative=res.data.datas[0].businessLegalRepresentative
              
              e.hrId=res.data.datas[0].hrId
              e.hrName=res.data.datas[0].hrName
              e.hrEmail=res.data.datas[0].hrEmail
              e.hrPhone=res.data.datas[0].hrPhone
  
              e.isAudit=res.data.datas[0].isAudit
              e.auditTime=res.data.datas[0].auditTime
              e.confirmTime=res.data.datas[0].confirmTime
              e.auditState=res.data.datas[0].auditState
              e.operationType=res.data.datas[0].operationType
              e.auditResultContent=res.data.datas[0].auditResultContent
              preAuditEInfoDialog.value=true
          } else if (res.data["code"] == "300") {
              elmessage(res.data["message"], res.data["type"])
              setTimeout(() => {
                  router.replace("/login")
              }, 500);
              localStorage.clear()
          } else {
              console.log(res.data);
  
          }
  
      })
  }
  const handleShowJObInfo=(index: number, row: ES)=>{
    getPreAuditEnterpriseInfo(row.auditId)
  }
  
  const closePreAuditEInfoDialog=()=>{
    preAuditEInfoDialog.value=false
  }
  
  
  const init=()=>{
    eGetAuditEnterprise(data()).then((res:any)=>{
      if (res.data["code"] == "200") {
        res.data.datas.forEach((value: any, index: any, self: any) => {
          tableData.push({...value})
        })
      } else if (res.data["code"] == "300") {
        elmessage(res.data["message"], res.data["type"])
        setTimeout(() => {
          router.replace("/login")
        }, 500);
        localStorage.clear()
      } else {
        console.log(res.data);
  
      }
    })
  }
  
  onBeforeMount(() => {
    init()
  })
  
  
  </script>
  <style scoped>
  .pagination{
    float: right;
    margin-right: 50px;
    /* right: 150px; */
  }
  .resume_center {
    font-family: '微软雅黑';
    height: 800px;
    background-color: #FFF;
  }
  
  .resume_header {
    background-color: rgb(215, 215, 215);
    height: 50px;
    display: flex;
    align-items: center;
    padding-left: 20px;
    justify-content: space-between;
  }
  
  a {
    text-decoration: none;
    color: #000;
  }
  </style>